import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '@/views/login/index.vue'
import Home from '@/views/home/index.vue'
import HomeMain from '@/views/home/conponent/main.vue'
import HomeDetails from '@/views/home/conponent/details.vue'
import Order from '@/views/order/index.vue'
import Shopping from '@/views/shopping/index.vue'
import Item from '@/views/home/conponent/item.vue'

Vue.use(VueRouter)

const originalPush = VueRouter.prototype.push

VueRouter.prototype.push = function push(location) {
  return originalPush.call(this,location).catch(err=>err)
}

const routes = [
  {
    path: '/',
    component: Home,
    children: [
      {
        path:"",
        component: HomeMain
      },
      {
        path: "details",
        component: HomeDetails
      },
      {
        path: "item",
        component: Item
      }
    ]
  },
  {
    path: '/login',
    component: Login
  },
  {
    path: '/order',
    component: Order
  },
  {
    path: '/shopping',
    component: Shopping
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
